package com.meilai.project.service.system.impl;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.meilai.project.entity.system.MediaTypeSpecPrice;
import com.meilai.project.mapper.system.MediaTypeSpecPriceMapper;
import com.meilai.project.service.system.MediaTypeSpecPriceService;
import com.meilai.project.vo.business.media.MediaTypeSpecPriceVO;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 点位类型-规格-价格 服务实现类
 * </p>
 *
 * @author haiYangX
 * @since 2022-05-28
 */
@Service
public class MediaTypeSpecPriceServiceImpl extends ServiceImpl<MediaTypeSpecPriceMapper, MediaTypeSpecPrice> implements MediaTypeSpecPriceService {

    @Override
    public Page<MediaTypeSpecPrice> list(Integer current_page, Integer page_size, Long media_type_spec_id) {
        Page<MediaTypeSpecPrice> page = new Page<>(current_page, page_size);
        return this.page(page, Wrappers.<MediaTypeSpecPrice>lambdaQuery().eq(MediaTypeSpecPrice::getMedia_type_spec_id, media_type_spec_id).orderByDesc(MediaTypeSpecPrice::getSort, MediaTypeSpecPrice::getId));
    }

    @Override
    public List<MediaTypeSpecPriceVO> allList() {
        return baseMapper.allList(null);
    }

    @Override
    public List<MediaTypeSpecPriceVO> list(Long media_type_spec_id) {
        return baseMapper.allList(media_type_spec_id);
    }

    @Override
    public List<MediaTypeSpecPriceVO> listByIdList(List<Long> media_type_spec_id_list) {
        if (CollUtil.isEmpty(media_type_spec_id_list)) {
            return new ArrayList<>();
        }
        return baseMapper.listByIdList(media_type_spec_id_list);
    }

    @Override
    public List<MediaTypeSpecPrice> listHasMediaTypeId(List<Long> ids) {
        return baseMapper.listHasMediaTypeId(ids);
    }
}
